# Configure system boilerplate
import os, sys
sys.path.append(os.environ.get('CONFIG_SCRIPTS_HOME', '../config'))
import config

# Version
version = '0.0.27'
major, minor, revision = version.split('.')

# Setup
env = config.make_env(['compiler', 'libprotomol', 'dist', 'build_info'])

env.__setitem__('static', os.getenv('STATIC_BUILD', 1)) # static build
env.__setitem__('fah', 1) # Always use fah
env.__setitem__('gromacs', 1) # Always use gromacs

# Configure
conf = Configure(env)

config.configure('build_info', conf, namespace = 'FAH::BuildInfo',
                 version = version)
config.configure('dist', conf, version = version)

if not env.GetOption('clean'):
  # Configure compiler
  config.configure('compiler', conf)

  # libprotomol-fah
  config.configure('libprotomol', conf)


info = env.BuildInfo('build_info.cpp', [])
AlwaysBuild(info)

# Main
src = ['protomol.cpp', info]
name = 'FahCore_b4'
Default(env.Program(name, src))

# Dist
distfiles = [name + env['PROGSUFFIX']]
if env['PLATFORM'] == 'win32': distfiles.append(name + '.exe.pdb')
tar = env.TarBZ2Dist('Protomol-FAHCore', distfiles)
Alias('dist', tar)
AlwaysBuild(tar)
